/*

    This file is part of Blue Violin.

    Blue Violin is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Blue Violin is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero Public License for more details.

    You should have received a copy of the GNU Affero Public License
    along with Blue Violin.  If not, see <http://www.gnu.org/licenses/>.

    Blue Violin  Copyright (C) 2008  Blue Violin, Inc. & Josh Watts <josh.watts@blueviolin.org>
	For more information, visit http://www.blueviolin.org/

    This program comes with ABSOLUTELY NO WARRANTY.

*/

function FileBodyLoad()
{
	var txtFileName = $get("txtFileName");
	var divFileList = $get("divFileList");
	var nChildren = divFileList.childNodes.length;
	var oNode = null;
	var i = 0;

	txtFileName.style.width = (document.body.clientWidth - 10) + "px";

	for (i = 0;
		 i < nChildren;
		 ++i)
	{
		oNode = divFileList.childNodes.item(i);
		oNode.attachEvent("onclick",
						  $createDelegate(oOpenFile, oOpenFile.select));
		oNode.attachEvent("ondblclick",
						  $createDelegate(oOpenFile, oOpenFile.selectAndOpen));
		
	}

	document.body.attachEvent("onkeypress",
							  $createDelegate(oOpenFile, oOpenFile.keyPress));

	$get("btnOpen").attachEvent("onclick",
								$createDelegate(oOpenFile, oOpenFile.open));
	$get("btnCancel").attachEvent("onclick",
								  $createDelegate(oOpenFile, oOpenFile.cancel));
	
}



function SaveFileBodyLoad()
{
	var txtFileName = $get("txtFileName");
	var divFileList = $get("divFileList");
	var nChildren = divFileList.childNodes.length;
	var oNode = null;
	var i = 0;

	
	txtFileName.style.width = (document.body.clientWidth - 10) + "px";
	for (i = 0;
		 i < nChildren;
		 ++i)
	{
		oNode = divFileList.childNodes[i];
		oNode.attachEvent("onclick",
						  $createDelegate(oSaveFile, oSaveFile.select));
		oNode.attachEvent("ondblclick",
						  $createDelegate(oSaveFile, oSaveFile.selectAndSave));
	}
	
	document.body.attachEvent("onkeypress",
							  $createDelegate(oSaveFile, oSaveFile.keyPress));
	
	$get("btnSave").attachEvent("onclick",
								$createDelegate(oSaveFile, oSaveFile.save));
	$get("btnCancel").attachEvent("onclick",
								  $createDelegate(oSaveFile, oSaveFile.cancel));
	
}



